package com.tdzx.entity;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.tdzx.util.StringUtils;

public class ImageEntity {
	private String goods_id;
	private String pic_url;
	private String goodsname;
	private String pic_id;
	
	public String getPic_id() {
		return pic_id;
	}
	public void setPic_id(String pic_id) {
		this.pic_id = pic_id;
	}
	public String getGoods_id() {
		return goods_id;
	}
	public void setGoods_id(String goods_id) {
		this.goods_id = goods_id;
	}
	public String getPic_url() {
		return pic_url;
	}
	public void setPic_url(String pic_url) {
		this.pic_url = pic_url;
	}
	public String getGoodsname() {
		return goodsname;
	}
	public void setGoodsname(String goodsname) {
		this.goodsname = goodsname;
	}
	
	
	public static List<ImageEntity> getImages(String json) {
		List<ImageEntity> list = null;
		try {
			JSONObject jo = new JSONObject(json);
			if(StringUtils.isSuccessTD(json)) {
				JSONArray ja = jo.optJSONArray("resutObject");
				if(ja != null) {
					list = new ArrayList<ImageEntity>();
					for(int i = 0; i < ja.length(); i++) {
						ImageEntity ie = new ImageEntity();
						JSONObject jo_ie = ja.optJSONObject(i);
						ie.setGoods_id(jo_ie.optString("goods_id"));
						ie.setGoodsname(jo_ie.optString("goodsname"));
						ie.setPic_url(jo_ie.optString("pic_url"));
						ie.setPic_id(jo_ie.optString("pic_id"));
						list.add(ie);
					}
				}
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return list;
	}

}
